home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / pavt117.zip / PAVTDEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1991-12-23  |  3KB  |  120 lines

  1. program PAvtDemo; { Demo of Avatar level 1 console using Crt routines }
  2.                   { Public Domain.  Author: Gregory P. Smith          }
  3.                   { Modification History:                             }
  4.                   {        07/06/91   First Coding                    }
  5.                   {        09/15/91   Added MoveW & FillWord          }
  6.                   {                   procedures to speed up 30%      }
  7.                   {        10/05/91   Combined the the PAvt0 & 1      }
  8.                   {                   demos into one program.  Also   }
  9.                   {                   placed the hooks in AVIDEO.INC  }
  10.                   {        12/23/91   Added coordinate checks on all  }
  11.                   {                   Screen Manipluations            }
  12. {$D-,L-,R-,F-,M 4096,4096,4096}
  13.  
  14. { DEFINE AVT0} { enabling this uses PAvt0 instead of PAvt1. }
  15.  
  16. Uses Dos, Crt,
  17. {$IFDEF AVT0}
  18.      PAvt0;
  19. {$ELSE}
  20.      PAvt1;
  21. {$ENDIF}
  22.  
  23. {$I AVIDEO.INC -- link in the screen I/O and user hooks. }
  24.  
  25. function UpStr(s:string): string;
  26. var
  27.   ns : string;
  28.   i : integer;
  29. begin
  30.   for i := 1 to length(s) do
  31.    ns[i] := upcase(s[i]);
  32.   ns[0] := s[0];
  33.   UpStr := ns;
  34. end;
  35.  
  36. procedure Help;
  37. begin
  38. {$IFDEF AVT0}
  39.   Writeln('PAvt0 Demo  Copr. 1991 Greg Smith');
  40. {$ELSE}
  41.   Writeln('PAvt1 Demo  Copr. 1991 Greg Smith');
  42. {$ENDIF}
  43.   Writeln('Usage:  PAVTDEMO [params] input_file [params]');
  44.   Writeln;
  45.   Writeln(' parameters (may be abbreviated):');
  46. {$IFNDEF AVT0}
  47.   Writeln('   /PLUS         Run in AVT/0+ simulation mode w/ ANSI fallback.');
  48. {$ENDIF}
  49.   Writeln('   /ANSI         Start with ANSI child active.');
  50.   Writeln('   /SLOW         Slow down emulation for viewing.');
  51.   halt;
  52. end;
  53.  
  54. var
  55.   fname : pathstr;
  56.  
  57. const
  58.   slowdown : byte = 0; { milliseconds between characters. }
  59.  
  60. procedure ProcessParams;
  61. const
  62.   Prms = '/PLUS/ANSI/SLOW/?/HELP';
  63. var
  64.   i,p : integer;
  65. begin
  66.   p := paramcount;
  67.   while p > 0 do
  68.    begin
  69.      i := pos(UpStr(ParamStr(p)),Prms);
  70.      case i of
  71. {$IFNDEF AVT0}
  72.        1  : Level0_Simulation(True);
  73. {$ENDIF}
  74.        6  : ANSI_Only;
  75.        11 : Slowdown := 2; { set to ms between chars. }
  76.        16..18 : Help;
  77.      else
  78.       fname := ParamStr(p);
  79.      end; { case }
  80.      dec(p);
  81.    end; { while }
  82. end;  { processed in reverse so that first non-parameter is the filename }
  83.  
  84. Procedure ProgBody;
  85. var
  86.   f : file;
  87.   buf : Array[1..1024] of char;
  88.   i,z : word;
  89. begin
  90.   Assign(Output,''); Rewrite(Output);
  91.   Assign(Input,''); Reset(Input);
  92.   fname := '';
  93. {$IFNDEF AVT0}
  94.   ANSI_BBS := True;
  95. {$ENDIF}
  96.   SetScrPtr;
  97.   SetHooks;
  98.   ProcessParams;
  99.   if fname = '' then Help;
  100.   FillArea(1,1,80,25,7,' '); { Clear Screen }
  101.   Assign(f,fname);
  102.   Reset(f,1);
  103.   repeat
  104.     BlockRead(f,buf,1024,z);
  105.     for i := 1 to z do
  106.      begin
  107.        Delay(slowdown);
  108.      {$IFDEF AVT0}
  109.        AvtInterp(buf[i]);
  110.      {$ELSE}
  111.        Parse_AVT1(buf[i]);
  112.      {$ENDIF}
  113.      end;
  114.   until EOF(f); { end else }
  115. end;
  116.  
  117. begin
  118.   ProgBody;
  119. end.
  120.